<template>
	<view class="content">
		<view class="login_avatar">
			<u-avatar mode="square" size="160"></u-avatar>
			<br/>
			<view class="title_font">复诊配药</view>
		</view>
<!-- 	<u-button shape="circle" class="loginbutton">
			<u-icon name="weixin-fill"></u-icon>
			微信快捷登录
		</u-button> -->
<!-- 		<navigator url="dispensing/doctor_dispensing">
			<button class="loginbutton" >
				<u-icon name="weixin-fill"></u-icon>
				微信快捷登录
			</button>
		</navigator> -->
		<button class="loginbutton" @click="toPath()">
			<u-icon name="weixin-fill"></u-icon>
			微信快捷登录
		</button>
	</view>
</template>

<script>
	export default {
		data(){
			return{
				
			}
		},
		methods:{
			toPath(){
					uni.getUserProfile({
						desc:'登录',
						success:function success(res){
							console.log(res)
						},
						complete:(res)=>{
							uni.request({
							    url: getApp().globalData.hostip+'Demo/doctor/getById?id='+res.userInfo.nickName, 
							    data: {
							    },
								fail:(fa) =>{
									console.log(fa)
								},
							    success: (res2) => {
									console.log(res2.data.state)
									if(res2.data.state){
										getApp().globalData.userinfo=res.userInfo;
										uni.request({
										    url: getApp().globalData.hostip+'Demo/doctor/getById?id='+res.userInfo.nickName, 
										    data: {
										    },
											fail:(fa) =>{
												console.log(fa)
											},
										    success: (res2) => {
												console.log(res2.data)
												getApp().globalData.doctorinfo=res2.data.doctor
										    }
										});
										uni.switchTab({
											url:"doctor_mainpage"
										})
									}
									else{
										console.log("false")
										getApp().globalData.userinfo=res.userInfo;
										uni.navigateTo({
											url:"doctor_registerpage"
										})
									}
							    }
							});
							// console.log(res.userInfo.nickName)
						}
					})
					// uni.switchTab({
					// 	url:"doctor_mainpage"
					// })
				}
		}
	}
</script>

<style scopped>
	page{
		background-color: #f5f5f5;
	}
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		padding: 40rpx;
		text-align: center;
	}
	.loginbutton{
		color: #FFFFFF;
		background-color: #09B805;
		width: 500rpx;
		border-radius: 60rpx;
		font-size: 36rpx;
	}
		
	.login_avatar{
		margin-top: 150rpx;
		margin-bottom: 200rpx;
	}
	.title_font{
		color: #666666;
		font-size: 36rpx;
	}
</style>
